# Maintainer: Frank Oltmanns <alpine@oltmanns.dev>
pkgname=py3-git-versioner
pkgver=7.1
pkgrel=1
pkgdesc="Manage current / next version for project"
url="https://gitlab.com/alelec/__version__"
arch="noarch"
license="MIT"
depends="py3-setuptools"
makedepends="
	py3-wheel
	py3-gpep517"
source="https://gitlab.com/alelec/__version__/-/archive/v$pkgver/__version__-v$pkgver.tar.gz"
subpackages="$pkgname-pyc"
builddir="$srcdir/__version__-v$pkgver"

prepare() {
	default_prepare

	# The wheel needs to be built twice for bootstrapping.
	# The first build creates a wheel with version number 0.0.0
	msg "Bootstrapping ..."
	GIT_VERSIONER_VERSION_PY=$pkgver \
	    gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
	# Remove the first build
	rm -r .dist
}

build() {
	# Now build again to build the wheel with the correct version number
	GIT_VERSIONER_VERSION_PY=$pkgver \
	    gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python test.py
}

package() {
	gpep517 install-wheel --destdir "$pkgdir" .dist/*.whl
	install -Dm644 LICENSE  -t "$pkgdir"/usr/share/licenses/"$pkgname"
}

sha512sums="
34b6fb4ad5bcec3c3ba78451c6c9716b330aca11e4752daa8ddaad6c1fbd1ddc9f263e24263bb02e96e28df656cf9c04f31cc67ac6edd8d025f82a7a77b54f46  __version__-v7.1.tar.gz
"
